import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/user/center'),
        name: 'dashboard',
        meta: { title: '首页', icon: 'account', noCache: true }
      }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/employee',
    component: Layout,
    name: 'Employee',
    meta: { title: '员工管理', icon: 'employeelist', roles: ['6', '8'] },
    redirect: '/employee/list',
    children: [
      {
        path: 'list',
        name: 'EmployeeList',
        component: () => import('@/views/employee/list'),
        meta: { title: '员工信息管理', icon: 'employeelist' }
      },
      {
        path: 'group',
        name: 'EmployeeGroup',
        component: () => import('@/views/employee/group'),
        meta: { title: '分组信息管理', icon: 'employeegroup' }
      }
    ]
  },
  {
    path: '/category',
    component: Layout,
    name: 'Category',
    meta: { title: '', icon: 'categorylist', roles: ['6', '8'] },
    redirect: '/category/list',
    children: [
      {
        path: 'list',
        name: 'CategoryList',
        component: () => import('@/views/category/list'),
        meta: { title: '分类管理', icon: 'categorylist' }
      }
    ]
  },
  {
    path: '/hospital',
    component: Layout,
    name: 'Hospital',
    meta: { title: '医院信息管理', icon: 'hospitallist', roles: ['6', '8'] },
    redirect: '/hospital/list',
    children: [
      {
        path: 'list',
        name: 'HospitalList',
        component: () => import('@/views/hospital/list'),
        meta: { title: '医院管理', icon: 'hospitallist' }
      },
      {
        path: 'department',
        name: 'HospitalDepartment',
        component: () => import('@/views/hospital/department'),
        meta: { title: '科室管理', icon: 'hospitaldepartment' }
      },
      {
        path: 'doctor',
        name: 'HospitalDoctor',
        component: () => import('@/views/hospital/doctor'),
        meta: { title: '医生管理', icon: 'hospitaldoctor' }
      },
      {
        path: 'cloth',
        name: 'HospitalCloth',
        component: () => import('@/views/hospital/cloth'),
        meta: { title: '工作服管理', icon: 'hospitalclothes' }
      }
    ]
  },
  {
    path: '/report',
    component: Layout,
    name: 'Report',
    meta: { title: '运营报表', icon: 'report', roles: ['6'] },
    redirect: '/report/in',
    children: [
      {
        path: 'in',
        name: 'ReportIn',
        component: () => import('@/views/report/in'),
        meta: { title: '进厂批次报表', icon: 'reportin' }
      },
      {
        path: 'out',
        name: 'ReportOut',
        component: () => import('@/views/report/out'),
        meta: { title: '出厂批次报表', icon: 'reportout' }
      },
      {
        path: 'daywork',
        name: 'ReportDayWork',
        component: () => import('@/views/report/daywork'),
        meta: { title: '日工作量统计表', icon: 'reportdaywork' }
      },
      {
        path: 'mouthtype',
        name: 'ReportMouthType',
        component: () => import('@/views/report/mouthtype'),
        meta: { title: '月度品类报表', icon: 'reportmouthtype' }
      },
      {
        path: 'hospital',
        name: 'ReportHospital',
        component: () => import('@/views/report/hospital'),
        meta: { title: '医院总表', icon: 'reporthospital' }
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

